package com.baidu.day03;

import java.io.File;
// 修改文件夹中所有文件名
public class Demo04 {

    public static void main(String[] args) {
        //获取到指定的文件夹
        File f = new File("C:\\Users\\14288\\Desktop\\aaa");
        changeName(f);
    }

    public static void changeName(File f) {
        File[] files = f.listFiles();
        for (File a : files) {
            if (a.isDirectory()) {
                changeName(a);
            }
            String parent = a.getParent();
            File newName = new File(parent + "\\" + "yyf" + a.getName());
            a.renameTo(newName);
        }
    }
}
